//多个对象+弹性运动+摩擦

function doMove(obj, attr, target){
	obj.iSpeed = 0;

	clearInterval(obj.timer);
	obj.timer = setInterval(function (){
		iCur = parseInt(getStyle(obj, attr));
		obj.iSpeed += (target - iCur)/5;
		obj.iSpeed *= 0.7;
		iCur += obj.iSpeed;

		obj.style[attr] = iCur + 'px';

		if (Math.abs(target - iCur) < 1 && Math.abs(obj.iSpeed) < 1) {			//离终点的距离和速度都很小
			obj.style[attr] = target + 'px';
			clearInterval(obj.timer)
		};
	},30);
}

function getStyle(obj, attr){
	return obj.currentStyle ? obj.currentStyle : getComputedStyle(obj)[attr];
}